﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PloobsEngine.MessageSystem;
using PloobsEngine.Events;

namespace PloobsEngine.Trigger
{
    public class TriggerEvent : IEvent<ITrigger>
    {
        String groupName;
        String triggerName;

        public String TriggerName
        {
            get { return TriggerName; }
            set { TriggerName = value; }
        }
        
        /// <summary>
        /// Cria um Evento q sera disparado qd um trigger for acionado
        /// </summary>
        /// <param name="groupName"></param>
        public TriggerEvent(String groupName,String TriggerName)
        {
            this.groupName = groupName;
            this.triggerName = TriggerName;
        }

        #region IEvent Members

        public void FireEvent(ITrigger trigger)
        {
            Message me = new Message(PrincipalConstants.EventSenderId, -1, groupName, Priority.LOW, 0, SenderType.EVENT, trigger, this.Code);
            MessageDeliver.SendMessage(me);           
        }

        #endregion

        #region IEvent<ITrigger> Members


        public string Code
        {
            get;
            set;
        }

        #endregion        
    }
}
